#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int kMaxN = 2010;
const int kInf = 1e9;

int g[kMaxN][kMaxN];
int dist[kMaxN], f[kMaxN];

void Dijkstra(int n) {
  priority_queue<pair<int, int>> pq;
  vector<int> order;

  fill(dist, dist + n + 1, kInf);
  dist[1] = 0;
  pq.emplace(-dist[1], 1);
  while (!pq.empty()) {
    int d = -pq.top().first, u = pq.top().second;

    pq.pop();
    if (dist[u] != d) {
      continue;
    }
    order.emplace_back(u);
    for (int v = 1; v <= n; v++) {
      if (dist[v] > d + g[u][v]) {
        dist[v] = d + g[u][v];
        pq.emplace(-dist[v], v);
      }
    }
  }
  if (dist[n] != kInf) {
    f[n] = 1;
  }
  for (int i = order.size() - 1; i >= 0; i--) {
    int u = order[i];

    for (int v = 1; v <= n; v++) {
      if (dist[u] + g[u][v] == dist[v]) {
        f[u] += f[v];
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, e;

  cin >> n >> e;
  for (int i = 1; i <= n; i++) {
    fill(g[i], g[i] + n + 1, kInf);
  }

  for (int i = 0; i < e; i++) {
    int u, v, w;

    cin >> u >> v >> w;
    g[u][v] = min(g[u][v], w);
  }
  Dijkstra(n);
  if (f[1]) {
    cout << dist[n] << " " << f[1] << "\n";
  } else {
    cout << "No answer\n";
  }
  return 0;
}